import http from '../utils/http.js'
import axios from 'axios'

//查询所有作者数据
function showAllauthor(val) {
    return http({
        method: 'post',
        url: '/admin/writerInfo/showWriterInfo',
        params:{
            page:val,
            limit:1000
        }
    })
}

// 通过作者姓名、状态模糊查询作者信息数据
function showWriterByStateOrWriterName(params){
    return http({
        method: 'post',
        url: '/admin/writerInfo/showWriterByStateOrWriterName',
        params:{
            ...params,
            page:1,
            limit:1000
            
        }
    })
}

// 添加作者
function addWriterInfo(params){
    return http({
        method: 'post',
        url: '/admin/writerInfo/addWriterInfo',
        params:params
        
    })
}
// 批量修改作者状态
function updateWriterState(params,str){
    return http({
        method: 'post',
        url: '/admin/writerInfo/updateWriterState',
        params:{
            ids:[...params],
            state:str
        }
    })
}
// 编辑作者信息
function updateWriterInfo(params){
    return http({
        method: 'post',
        url: '/admin/writerInfo/updateWriterInfo',
        params:params 
        
    })
}
// 上传头像
function uploadWriterImage(file){
    console.log('file',file)
   return  axios({
        method: 'post',
        url: 'http://42.192.83.237:8080/admin/content/uploadContentImage',
        headers: {
            "Content-Type": "multipart/form-data",
            token:sessionStorage.getItem('token')
        },
        data: {
            mpFile:file
        }
    })
}
// 删除作者
function deleteWriterInfo(params){
    return http({
        method: 'post',
        url: '/admin/writerInfo/deleteWriterInfo',
        params:{ids:[...params]}
            
        
    })
}

export {
    showAllauthor,
    showWriterByStateOrWriterName,
    uploadWriterImage,
    addWriterInfo,
    updateWriterState,
    updateWriterInfo,
    deleteWriterInfo
   
}